<template>
	<section>
		<!--工具条-->
		<el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
			<el-form :inline="true" :model="filters">
				<el-form-item>
					<el-input v-model="query.keyword" placeholder="名称"></el-input>
				</el-form-item>
				<el-form-item>
					<el-button type="primary" v-on:click="getPermissions">查询</el-button>
				</el-form-item>
			</el-form>
		</el-col>

    <!--列表-->
    <el-table :data="pageInfo.rows" highlight-current-row v-loading="listLoading" style="width: 100%;">
      <el-table-column type="index" width="60">
      </el-table-column>
      <el-table-column prop="name" label="名字" width="150">
      </el-table-column>
      <el-table-column prop="url" label="路径" width="130">
      </el-table-column>
      <el-table-column prop="sn" label="唯一标识" width="300">
      </el-table-column>

      <el-table-column prop="parent.name" label="父权限" min-width="100">
      </el-table-column>


      <el-table-column prop="descs" label="描述" width="120">
      </el-table-column>
    </el-table>

    <!--工具条-->
    <el-col :span="24" class="block">
      <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="query.currentPage"
          :page-sizes="[10, 20, 30, 40]"
          :page-size="10"
          layout="total, sizes, prev, pager, next, jumper"
          :total="pageInfo.total"
          style="float:right;">
      </el-pagination>
    </el-col>


	</section>
</template>

<script>
	// import util from '../../common/js/util'
	// //import NProgress from 'nprogress'
	// import { getUserListPage, removeUser, batchRemoveUser, editUser, addUser } from '../../api/api';

	export default {
		data() {
			return {
				filters: {
					name: ''
				},
        pageInfo: {
				  rows:[],
          total:0
        },
        query: {
          currentPage: 1,
          pageSize: 10,
          keyword:""
        },

				total: 0,
				page: 1,
				listLoading: false,


				saveLoading: false,
				//编辑界面数据

				saveFormRules: {
					name: [
						{ required: true, message: '请输入姓名', trigger: 'blur' }
					]
				},


			}
		},
		methods: {
      //性别显示转换
      formatSex: function (row, column) {
        return row.sex == 1 ? '男' : row.sex == 0 ? '女' : '未知';
      },
      handleCurrentChange(val) {
        this.query.currentPage = val;
        this.getPermissions();
      },
      handleSizeChange(val) {
        this.query.pageSize = val;
        this.getPermissions();
      },
      getPermissions() {
        this.listLoading = true;
        //NProgress.start();

        this.$http.post("/permission", this.query).then(result => {
          this.listLoading = false;
          if (result.data.success) {
            console.log("total")
            console.log(result.data.obj.total);
            this.pageInfo.rows = result.data.obj.pageList;

            this.pageInfo.total = result.data.obj.total;
          } else {
            this.$message({
              message: '查询失败',
              type: 'info'
            });
          }
        })
      }
    },
			//删除
		mounted() {
			this.getPermissions();
		}
	}

</script>

<style scoped>

</style>